/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

#ifndef SELECT_ENTITIES_COMMAND_H
#define SELECT_ENTITIES_COMMAND_H

#include <QUndoCommand>
#include <QStringList>

#include "../EntityExplorer.h"
#include "../Entity.h"

class SelectEntitiesCommand : public QUndoCommand
{
public:
    SelectEntitiesCommand( EntityExplorer* entityExplorer,
            QList<Entity*> newValue,
            QList<Entity*> oldValue,
            QUndoCommand *parent = 0 )
            : QUndoCommand( parent ),
            entityExplorer( entityExplorer ),
            newValue( newValue ),
            oldValue( oldValue )
    {
        if(newValue.size() > 0)
        {
            setText( "Select Entity \"" + newValue[newValue.size()-1]->name + "\"" );
        }
        else
        {
            setText( "Deselect all" );
        }
    }

    void undo()
    {
        entityExplorer->tree->clearSelection();
        entityExplorer->addEntitiesToSelection( oldValue );

//        if(newValue.size() > 0)
//        {
//            setText( "Select Entity \"" + newValue[newValue.size()-1]->name + "\"" );
//        }
    }

    void redo()
    {
        entityExplorer->tree->clearSelection();
        entityExplorer->addEntitiesToSelection( newValue );

//        if(newValue.size() > 0)
//        {
//            setText( "Select Entity \"" + newValue[newValue.size()-1]->name + "\"" );
//        }
    }

private:
    EntityExplorer *entityExplorer;
    QList<Entity*> newValue;
    QList<Entity*> oldValue;
};

#endif
